/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.web.taglib.head.css;

import javax.servlet.jsp.tagext.TagSupport;

import com.genia.toolbox.web.constant.SpringBeanNames;

/**
 * tag to register a new css link.
 */
@SuppressWarnings("serial")
public class SpringCssAddLink
    extends TagSupport
{

  /**
   * spring name where to get the UrlManager.
   */
  private String urlManagerName = SpringBeanNames.DEFAULT_URL_MANAGER_NAME;

  /**
   * the CSS link.
   */
  private String link = null;

  /**
   * the media of the link.
   */
  private String media = null;

  /**
   * the priority of the css link.
   */
  private int priority = 0;

  /**
   * the {@link CssLinkContainer} to use.
   */
  private CssLinkContainer cssLinkContainer;



  /**
   * getter for the urlManagerName property.
   * 
   * @return the urlManagerName
   */
  public String getUrlManagerName()
  {
    return urlManagerName;
  }



  /**
   * setter for the urlManagerName property.
   * 
   * @param urlManagerName
   *          the urlManagerName to set
   */
  public void setUrlManagerName(final String urlManagerName)
  {
    this.urlManagerName = urlManagerName;
  }



  /**
   * Processing of the start tag.
   * 
   * @return SKIP_BODY
   */
  @Override
  public int doStartTag()
  {
    getCssLinkContainer().addLink(getLink(), getMedia(), getUrlManagerName(), getPriority());
    return SKIP_BODY;
  }



  /**
   * Release state.
   */
  @Override
  public void release()
  {
    super.release();
    urlManagerName = SpringBeanNames.DEFAULT_URL_MANAGER_NAME;
    link = null;
    media = null;
    priority = 0;
  }



  /**
   * getter for the link property.
   * 
   * @return the link
   */
  public String getLink()
  {
    return link;
  }



  /**
   * setter for the link property.
   * 
   * @param link
   *          the link to set
   */
  public void setLink(final String link)
  {
    this.link = link;
  }



  /**
   * getter for the cssLinkContainer property.
   * 
   * @return the cssLinkContainer
   */
  public CssLinkContainer getCssLinkContainer()
  {
    return cssLinkContainer;
  }



  /**
   * setter for the cssLinkContainer property.
   * 
   * @param cssLinkContainer
   *          the cssLinkContainer to set
   */
  public void setCssLinkContainer(CssLinkContainer cssLinkContainer)
  {
    this.cssLinkContainer = cssLinkContainer;
  }



  /**
   * getter for the priority property.
   * 
   * @return the priority
   */
  public int getPriority()
  {
    return priority;
  }



  /**
   * setter for the priority property.
   * 
   * @param priority
   *          the priority to set
   */
  public void setPriority(int priority)
  {
    this.priority = priority;
  }



  /**
   * getter for the media property.
   * 
   * @return the media
   */
  public String getMedia()
  {
    return media;
  }



  /**
   * setter for the media property.
   * 
   * @param media
   *          the media to set
   */
  public void setMedia(String media)
  {
    this.media = media;
  }

}
